﻿@model CatalogPagingFilteringModel.SpecificationFilterModel
@{
    var notFilteredItemsGroups = Model.NotFilteredItems.GroupBy(x => x.SpecificationAttributeName);
}
@if (Model.Enabled)
{
    <div id="block-product-spec-filter" class="block product-filter product-spec-filter">
        <h2 class="h5">
            <strong>@T("Filtering.SpecificationFilter")</strong>
        </h2>
        <div class="filter-content viewBox">
            @if (Model.NotFilteredItems.Any())
            {
                <div class="available-items">
                    @foreach (var group in notFilteredItemsGroups)
                    {
                        var groupList = group.ToList();
                        <div class="col-12 px-0">
                            <ul class="group product-spec-group">
                                <li class="title">
                                    <span>
                                        @groupList[0].SpecificationAttributeName:
                                    </span>
                                </li>
                                <li>
                                    <div class="btn-group-sm d-inline-flex flex-wrap">
                                        @foreach (var spec in groupList)
                                        {

                                            @if (String.IsNullOrEmpty(spec.SpecificationAttributeOptionColorRgb))
                                            {
                                                <a class="p-0 mr-3 border-0 spec-link" href="@spec.FilterUrl">
                                                    @spec.SpecificationAttributeOptionName
                                                </a>
                                            }
                                            else
                                            {
                                                <a class="p-0 border-0 mb-0" href="@spec.FilterUrl">
                                                    <div class="color-squares">
                                                        <span class="color-container" title="@spec.SpecificationAttributeOptionName">
                                                            <span class="color" style="background-color: @(spec.SpecificationAttributeOptionColorRgb);">&nbsp;</span>
                                                        </span>
                                                    </div>
                                                </a>
                                            }

                                        }
                                    </div>
                                </li>
                            </ul>
                        </div>
                    }
                </div>
            }
        </div>
        @if (Model.AlreadyFilteredItems.Any())
        {
            <div class="filtered-items">
                <ul class="pl-0">
                    <li class="title">
                        @T("Filtering.SpecificationFilter.CurrentlyFilteredBy")
                    </li>
                    @foreach (var item in Model.AlreadyFilteredItems)
                    {
                        <li class="item">
                            <strong>@(item.SpecificationAttributeName):</strong> <a class="" href="@item.FilterUrl"> @item.SpecificationAttributeOptionName</a>
                        </li>
                    }
                </ul>
                <div class="remove-filter mb-1">
                    <a class="btn btn-secondary btn-sm" href="@Model.RemoveFilterUrl">@T("Filtering.SpecificationFilter.Remove")</a>
                </div>
            </div>
        }
    </div>
}